Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(Http): can optionally fetch local resources from app bundle with Http #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
vakrilov merged 1 commit into NativeScript:master from NathanWalker:http-local-semantics
Jun 23, 2016
Merged

feat(Http): can optionally fetch local resources from app bundle with Http #286

vakrilov merged 1 commit into NativeScript:master from NathanWalker:http-local-semantics
Jun 23, 2016

Conversation

@NathanWalker
Copy link
Contributor

@NathanWalker NathanWalker commented Jun 11, 2016

This provides a nice convenience for Angular developers; an easy way to fetch local files with Http from their app bundle just like they would local files in their web app using the same semantics as NativeScript XML Image src property.

this.http.get(`~/assets/data.json`)
 .map((response: Response) => response.json())
 .subscribe((results: string[]) => {
 // we have results!
 });

... is now possible 👍

triniwiz reacted with thumbs up emoji
Copy link
Contributor Author

This now has tests with helpful mocks 👍

Copy link
Contributor Author

NathanWalker commented Jun 22, 2016
edited
Loading

As far as any debate around "is it right to allow Http module to request local files"... the main question is does Http allow local files to be requested from a web server, and the answer is ​_Yes_​. That’s how web devs see it... If a file is in their web app and it can be requested via XMLHttpRequest, which it can, the same expectation will be brought to their approach to {N}... they will want to be able to intutively request files from their app with Http. This was one of those things when I started with nativescript-angular, I just expected to work and didn’t understand why it didnt... since i am a hardened web dev.

Outside of those logical reasons... it is just convenient sugar... and devs love sugar... it’s what makes for a happier dev experience imo.

Copy link
Contributor Author

NathanWalker commented Jun 22, 2016
edited
Loading

This PR also fixes the new error occuring for some folks with latest that's in rc2 and rc3 with Http

ORIGINAL EXCEPTION: Error: not implemented
ORIGINAL STACKTRACE:
Error: not implemented
 at NativeScriptDomAdapter.Parse5DomAdapter.getCookie (/data/data/org.nativescript.nativescriptweather/files/app/tns_modules/@angular/platform-server/src/parse5_adapter.js:612:68)

Copy link
Contributor

👍

1 similar comment
Copy link
Contributor

hdeshev commented Jun 23, 2016

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /